<?php
    $select_faq='SELECT * FROM faq ORDER BY faq_id DESC';
	$res_faq=mysql_query($select_faq);
	
	$select_u=mysql_query('SELECT type, username FROM users WHERE username="'.$_SESSION['username'].'"');
    $row_u=mysql_fetch_assoc($select_u);
	
	if(mysql_num_rows($res_faq)==0){
	   echo "<p style='margin-left: 5px; margin-right: 5px; position: relative; top: -10px; border: 2px dotted #3171a0; padding: 5px; font-weight: bold;'>Няма FAQ въпроси!</p>";
	} else {
	$i=1;
	if($_SESSION['username']=="admin"){
	while($row_faq=mysql_fetch_assoc($res_faq)){
	   echo '<p style="font-weight: bold; margin-left: 25px; margin-right: 25px;">'.$i.". ".$row_faq['vupros'].'</p>';
	   echo '<p id="otgovor'.$i.'" style="margin-left: 25px; margin-right: 25px; text-indent: 20px;">'.$row_faq['otgovor']."</p>";
	   echo '<hr style="width: 90%"/>';

	$i++;
	}
	} elseif($row_u['type']==2){
	while($row_faq=mysql_fetch_assoc($res_faq)){
	   echo '<p style="font-weight: bold; margin-left: 25px; margin-right: 25px;">'.$i.". ".$row_faq['vupros'].'</p>';
	   echo '<p id="otgovor'.$i.'" style="margin-left: 25px; margin-right: 25px; text-indent: 20px;">'.$row_faq['otgovor']."</p>";
	   echo '<hr style="width: 90%"/>';

	$i++;
	}
	}
	else{
	while($row_faq=mysql_fetch_assoc($res_faq)){
	   echo '<p style="font-weight: bold; margin-left: 25px; margin-right: 25px;">'.$i.". ".$row_faq['vupros'].'</p>';
	   echo '<p id="otgovor'.$i.'" style="margin-left: 25px; margin-right: 25px; text-indent: 20px;">'.$row_faq['otgovor']."</p>";
	   echo '<hr style="width: 90%"/>';

	$i++;
	}
	}
	}
	?>